<!-- eslint-disable vue/multi-word-component-names -->
<template>
    <link rel="stylesheet" href="/css/my.css">

    <div class="usercenter">
        <div class="header">
            <div class="header_title">
                <div class="title_avatar">
                    <img :src="business.avatar_text" />
                </div>
                <div class="title_content">
                    <div class="content_text">{{ business.nickname }}</div>
                    <div class="content_sm">{{ business.createtime_text }}</div>
                </div>
            </div>
            <div class="operate">
                <div class="text-sm">
                    <span class="text-bold">0</span>
                    收藏夹
                </div>
                <div class="text-sm">
                    <span class="text-bold">0</span>
                    关注店铺
                </div>
                <div class="text-sm">
                    <span class="text-bold">0</span>
                    足迹
                </div>
                <div class="text-sm">
                    <span class="text-bold">0</span>
                    全部订单
                </div>
            </div>
        </div>
        <!-- <div class="userorder">
            <div class="order_project">
                <div class="item">
                    <router-link to="/order/index" class="item">
                        <div class="img">
                            <img src="/images/order1.png" alt="">
                        </div>
                        全部订单
                    </router-link>
                </div>
                <div class="item">
                    <a href="order.html" class="item">
                        <div class="img">
                            <img src="/images/order2.png" alt="">
                        </div>
                        待发货
                    </a>
                </div>
                <div class="item">
                    <a href="order.html" class="item">
                        <div class="img">
                            <img src="/images/order3.png" alt="">
                        </div>
                        待收货
                    </a>
                </div>
                <div class="item">
                    <a href="order.html" class="item">
                        <div class="img">
                            <img src="/images/order4.png" alt="">
                        </div>
                        待评价
                    </a>
                </div>
                <div class="item solid-left">
                    <a href="order.html" class="item">
                        <div class="img">
                            <img src="/images/returns.png" alt="">
                        </div>
                        退货/售后
                    </a>
                </div>
            </div>
        </div> -->
        <div class="userorder">
            <div class="order_project">
                <div class="item">
                    <router-link to="/distri/index" class="item">
                        <div class="img"> <img src="/images/retail1.png" alt=""></div>
                        分销信息
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/distri/member" class="item">
                        <div class="img"> <img src="/images/retail2.png" alt=""></div>
                        分销会员
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/distri/money" class="item">
                        <div class="img"> <img src="/images/retail3.png" alt=""></div>
                        分销佣金
                    </router-link>
                </div>
                <div class="item">
                    <a href="mycoupon.html" class="item">
                        <div class="img"> <img src="/images/coupon.png" alt=""></div>
                        优惠列表
                    </a>
                </div>
                <div class="item solid-left">
                    <a href="deposit.html" class="item">
                        <div class="img"> <img src="/images/recharge2.png" alt=""></div>
                        充值中心
                    </a>
                </div>
            </div>
        </div>
        <div class="usertool">
            <div class="list">
                <div class="item">
                    <router-link to="/business/profile">
                        <div class="img">
                            <img src="/images/profile.png" alt="">
                        </div>
                        基本资料
                    </router-link>
                </div>
                <div class="item">
                    <router-link to="/order/index">
                        <div class="img">
                            <img src="/images/returns.png" alt="">
                        </div>
                        全部订单
                    </router-link>
                </div>
                <div class="item">
                    <a href="order.html">
                        <div class="img"> <img src="/images/pingtuan.png" alt=""></div>
                        拼团订单
                    </a>
                </div>
                <div class="item">
                    <router-link to="/address/index">
                        <div class="img"> <img src="/images/address.png" alt=""></div>
                        收货地址
                    </router-link>
                </div>
                <div class="item">
                    <a href="email.html">
                        <div class="img"> <img src="/images/email.png" alt=""></div>
                        邮箱认证
                    </a>
                </div>
                <div class="item">
                    <a href="record.html">
                        <div class="img"> <img src="/images/consume.png" alt=""></div>
                        消费记录
                    </a>
                </div>
                <div class="item">
                    <a href="record.html">
                        <div class="img"> <img src="/images/recharge1.png" alt=""></div>
                        充值记录
                    </a>
                </div>

                <div class="item">
                    <a href="javascript:void(0)" @click="logout">
                        <div class="img">
                            <img src="/images/logout_1.png" alt="">
                        </div>
                        退出登录
                    </a>
                </div>
            </div>
        </div>
        <div class="usertool">
            <ul class="proul" v-if="news">
                <li v-for="(item, key) in news" :key="key">
                    <div class="con">
                        <router-link :to="{ path: '/product/info', query: { pid: item.id } }">
                            <van-image width="100%" :height="176" fit="cover" :src="item.thumbs_text" />
                            <p><span>￥</span>{{ item.price }}</p>
                        </router-link>
                    </div>
                </li>
            </ul>
        </div>
        <div class="h54"></div>
        <div class="clear"></div>
    </div>

    <tabbar />
</template>

<script setup>
// // 引入公共底部文件
// import tabbar from '@/components/common/tabbar.vue'

import { getCurrentInstance } from 'vue'

import tabbar from '@/components/common/tabbar.vue'

//获取this对象
const { proxy } = getCurrentInstance()

// 获取个人资料信息
let business = proxy.$business

let logout = () => {
    proxy.$confirm({
        message: '是否确认退出',
    }).then(() => { //确认
        //删除cookie，跳转
        proxy.$cookies.remove('business')
        proxy.$cookies.remove('redirect')

        //退出到登录界面
        proxy.$router.push('/business/login')
        return
    }).catch(() => { })
}

// 创建数据
// eslint-disable-next-line no-undef
let top = ref([])
// eslint-disable-next-line no-undef
let news = ref([])

// 生命周期
// eslint-disable-next-line no-undef
onBeforeMount(() => {
    ProductData()
})

// 查询数据
const ProductData = async () => {
    var result = await proxy.$POST({ url: '/index/index' })

    if (result.code == 0) {
        proxy.$fail(result.msg)
        return false
    }

    top.value = result.data.top
    news.value = result.data.news
}
</script>